package com.steel.yfmall.cloud.assistant.controller;

import com.alibaba.fastjson.JSON;
import com.steel.yfmall.cloud.assistant.po.view.OutCallApiLogBean;
import com.steel.yfmall.cloud.components.mq.bean.RequestSendMQBean;
import com.steel.yfmall.cloud.components.mq.service.MqSendService;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;

/**
 * @author yuchaohua
 * @version V1.0
 * @Title: BaseController
 * @Package com.steel.yfmall.cloud.assistant.controller
 * @Description: (用一句话描述该文件做什么)
 * @date 2021/1/22 17:56
 */
@Slf4j
public class BaseController {

    @Resource
    protected MqSendService mqSendService;

    /**
     * 记录接口访问日志
     * @Title: addCommonCallApiLog
     * @Description: (这里用一句话描述这个方法的作用)
     * @Param paraStr 参数说明
     * @Param resultText 参数说明
     * @Param interfaceMethod 参数说明
     * @Param interfaceMethodName 参数说明
     * @return void    返回类型
     * @author yuchaohua
     * @date 2021/1/22 18:04
     */
    @SuppressWarnings("rawtypes")
    protected void addCommonCallApiLog(String paraStr, String resultText, String interfaceMethod ,String interfaceMethodName) {
        OutCallApiLogBean outCallApiLogBean = new OutCallApiLogBean();
        outCallApiLogBean.setParaText(paraStr);
        outCallApiLogBean.setInterfaceMethod(interfaceMethod);
        outCallApiLogBean.setInterfaceMethodName(interfaceMethodName);
        outCallApiLogBean.setResultText(resultText);
        outCallApiLogBean.setStatus(1);
        //下发mq，调整订单及交货单状态
        RequestSendMQBean requestSendMQBean = new RequestSendMQBean();
        requestSendMQBean.setSendMqTitle("insert_out_call_api_log");
        requestSendMQBean.setSendMqMessage(JSON.toJSONString(outCallApiLogBean));
        mqSendService.sendCommonMQMessage(requestSendMQBean);

    }

}
